Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chaining click events (double/triple click etc) #5369

Merged
merged 28 commits into from
Dec 11, 2024
Merged

Conversation

darrenburns
Copy link
Member

@darrenburns darrenburns commented Dec 9, 2024

  • Adds support for detecting double/triple clicks via chain attribute on Click events.
  • Updates pilot.click with a times argument, allowing double/triple/etc clicks.

This PR doesn't implement any features which make use of double/triple clicks.

Please review the following checklist.

  • Docstrings on all new or modified functions / classes
  • Updated documentation
  • Updated CHANGELOG.md (where appropriate)

@@ -4325,10 +4355,12 @@ def suspend(self) -> Iterator[None]:
# app, and we don't want to have the driver auto-restart
# application mode when the application comes back to the
# foreground, in this context.
# fmt: off
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ruff formats this code into parentheses, and you can't use parentheses in context managers on 3.8.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed by adding:

[tool.ruff]
target-version = "py38"

To pyproject.toml.

@@ -556,8 +557,88 @@ class Click(MouseEvent, bubble=True):

- [X] Bubbles
- [ ] Verbose

Args:
Copy link
Member Author

@darrenburns darrenburns Dec 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've copied the docstring format from other classes in this module, assuming inheritance etc. rather than copy pasting a huge docstring several times.

@darrenburns darrenburns marked this pull request as ready for review December 10, 2024 21:00
Copy link
Collaborator

@willmcgugan willmcgugan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments for your consideration.

docs/events/click.md Outdated Show resolved Hide resolved
You can simulate double and triple clicks by setting the `times` parameter.

```python
await pilot.click(Button, times=2) # Double click
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are calling times here and chain on the event?

I see why. It reads like "click button 2 times". But it feels inconsistent.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree it's a bit inconsistent but I think of the event being a lower level technical thing and as you said pilot interacting from the user POV.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about a pilot.double_click and pilot.triple_click (in addition to the times parameter?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added these

@darrenburns darrenburns merged commit 3c120c0 into main Dec 11, 2024
23 checks passed
@darrenburns darrenburns deleted the click-events branch December 11, 2024 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants